package Offer;

import java.util.PriorityQueue;

public class p40最小的k个数 {
    class Solution {
        public int[] getLeastNumbers(int[] arr, int k) {
            PriorityQueue<Integer> pq = new PriorityQueue<>();
            int[] res = new int[k];
            for (int j : arr) {
                pq.add(j);
            }
            for(int i = 0; i < k; i++){
                res[i] = pq.poll();
            }
            return res;
        }
    }
}
